﻿using com.guojin.core.io.message;
using com.guojin.mj.net.message.login;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class BuyRoomCardPage : EventManager
{
    private static BuyRoomCardPage instance;
    public static  BuyRoomCardPage GetInstance()
    {
        return instance;
    }
    void Awake()
    {
        instance = this;
    }


    public Text payWXNumber;
    public Button copyBtn;
    public Button closeBtn;
 
    public override void InformationSetting()
    {
        AddListenerToButton(copyBtn,  CopyBtnClick);
        AddListenerToButton(closeBtn, CloseBtnClick);
        #region
        //surplus.content = "当前余额："+GameData.GetInstance().RoomCard+"张";
        //payRoomCard.content = "";
        #endregion
    }

    public void OnReceiveMsg730(string msg, Message data)
    {
        if (GameObject.Find("BuyRoomCardPage(Clone)"))
        {
            ServiceWXRet swr = (ServiceWXRet)data;
            payWXNumber.text = string.Format("充值客服微信号：{0}", swr.payWX);
        }
        else
        {
            Debug.Log("7.30消息找不到BuyRoomCardPage面板！");
        }
    }

    void CopyBtnClick()
    {
        if (string.IsNullOrEmpty(payWXNumber.text))
        {
            Debug.Log("游戏充值微信号Text为空");
        }
        else
        {
            string str = payWXNumber.text.Substring(8);
            LoginAndShare.Controller.CopyTextToClipboard(str);
        }
    }

    #region
    //public Button pay5btn;
    //public Button pay100btn;
    //public Button pay200btn;
    //public Button pay100btn;
    //public Button pay80btn;
    //public Button pay160btn;
    //public Text surplus;
    ////public Text payRoomCard;
    //private int paynum;
    //public Button[] btnArray = new Button[6];
    //public   void OnClickBtn1()
    //{
    //    //SetBtnColor(0);
    //    //payRoomCard.content = "10";
    //    paynum = 1;
    //    SendPay();
    //}
    //public  void OnClickBtn2()
    //{
    //   // SetBtnColor(1);
    //    //payRoomCard.content = "22";
    //    paynum = 25;
    //    SendPay();
    //}
    //public    void OnClickBtn3()
    //{
    //    //SetBtnColor(2);
    //    //payRoomCard.content = "56";
    //    paynum = 60;
    //    SendPay();
    //}
    //public   void OnClickBtn4()
    //{
    //   // SetBtnColor(3);
    //   // payRoomCard.content = "120";
    //    paynum = 100;
    //    SendPay();
    //}
    //public    void OnClickBtn5()
    //{
    //   // SetBtnColor(4);
    //   // payRoomCard.content = "80";
    //    paynum = 80;
    //    SendPay();
    //}
    //public  void OnClickBtn6()
    //{
    //    //SetBtnColor(5);
    //    //payRoomCard.content = "160";
    //    paynum = 160;
    //    SendPay();
    //}
    //public void SendPay()
    //{
    //    if (isClick)
    //    {
    //        //发送微信支付消息给服务器 7, 27
    //        SHWXPay wxp = SHWXPay.Create(paynum, 0);
    //        SocketMgr.GetInstance().Send(com.guojin.mj.net.Net.instance.write(wxp));
    //        isClick = false;
    //        Debug.Log("发送购买房卡");
    //    }
    //    else
    //    {
    //        Debug.Log("已经发送过购买房卡了");
    //    }
    //}
    //bool isClick = true;
    //float timer = 0;
    //float interval = 3;
    //void Update()
    //{
    //    if (!isClick)
    //    {
    //        timer += Time.deltaTime;
    //        if (timer > interval)
    //        {
    //            timer = 0;
    //            isClick = true;
    //        }
    //    }
    //}
    #endregion
}
